package com.cake.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cake.base.util.ReturnUtils;
import com.cake.dao.XxOrderItemMapper;
import com.cake.dao.XxOrderMapper;
import com.cake.entity.XxOrder;
import com.cake.entity.pojo.OrderPoJo;
import com.cake.query.OrderQuery;
import com.cake.service.base.BaseService;
import com.cake.service.inter.IXxOrderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * 订单业务层
 * @author Administrator
 *
 */
@Service
@Transactional
public class XxOrderServiceImpl extends BaseService<XxOrder> implements IXxOrderService{

	@Autowired
	private XxOrderMapper xxOrderMapper;
	
	@Autowired
	private XxOrderItemMapper xxOrderItemMapper;
	
	@Override
	public ReturnUtils selectOrders(OrderQuery orderQuery) {
		PageHelper.startPage(orderQuery.getCurrentPage(), orderQuery.getPageSize());
		List<XxOrder> list = xxOrderMapper.selectOrders(orderQuery);
		PageInfo<XxOrder> page = new PageInfo<>(list);
		return ReturnUtils.forNoramlPage("000000", list, 
				page.getPageNum(), page.getPageSize(), page.getPages(), (int)page.getTotal());
	}

	@Override
	public ReturnUtils selectOrderByOrderId(Long orderId) {
		return ReturnUtils.forNoramlSuccess(xxOrderMapper.findOrderDetail(orderId));
	}

	
	
}
